<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023/11/8
  Time: 16:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="${path}/assets/js/jquery-3.7.1.min.js"></script>
    <style>
        #app{
            width: 400px;
            height: 400px;
            border: 1px solid #cccccc;
            background-color: bisque;
        }
    </style>
</head>
<body>
<h1>欢迎登录</h1>
<div id="app">
    <form action="#">
        用户名:
        <input type="text" name="user_name" id="user_name" />
        <br/>
        密码:
        <input type="password" name="user_pwd" id="user_pwd"/>
        <br/>
        <button type="button" id="btn">登录</button>
    </form>

</div>



<script type="text/javascript">
   $("#btn").on('click' , function (){
       $.ajax({
           method : 'post',
           url : "user_login",
           data : {
               userName : $("#user_name").val(),
               userPwd : $("#user_pwd").val()
           },
           success : function (data){
               if(data){
                   window.location.href = "login_success";
               }else{
                   alert("登录失败");
                   window.location.href = "login_page";
               }
           }


       })
   });
</script>

</body>
</html>
